<!DOCTYPE html>





<html class="theme-next gemini use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/penguin-32px-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/penguin-16px-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.3.0',
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":true},
    save_scroll: false,
    copycode: {"enable":false,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="为了丰富员工业余生活，增多交流机会，于是在公司搭建了论坛方便大家灌水，目前公司中企业级应用是基于JAVAEE的产品，论坛选用了比较受欢迎的Discuz 3.2, 为了避免二次登陆使用单点登陆解决，虽然查找了各种资料做集成，但是其中还是遇到了些问题，翻墙发现了：discuz-ucenter-api-for-java因为被墙，在国内无法访问code.google.com，已将测试代码做了部分调整上传至">
<meta name="keywords" content="java,web,discuz,php,单点登录">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaWeb整合Discuz实现单点登录">
<meta property="og:url" content="https://crazyrico.com/posts/2016/09/26/344d9fc6.html">
<meta property="og:site_name" content="疯狂的企鹅">
<meta property="og:description" content="为了丰富员工业余生活，增多交流机会，于是在公司搭建了论坛方便大家灌水，目前公司中企业级应用是基于JAVAEE的产品，论坛选用了比较受欢迎的Discuz 3.2, 为了避免二次登陆使用单点登陆解决，虽然查找了各种资料做集成，但是其中还是遇到了些问题，翻墙发现了：discuz-ucenter-api-for-java因为被墙，在国内无法访问code.google.com，已将测试代码做了部分调整上传至">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://static.nsoft.vip/16-9-18-7630535.jpg">
<meta property="og:image" content="http://static.nsoft.vip/16-9-18-57860485.jpg">
<meta property="og:image" content="http://static.nsoft.vip/16-9-18-19780976.jpg">
<meta property="og:updated_time" content="2019-10-16T08:06:47.606Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="JavaWeb整合Discuz实现单点登录">
<meta name="twitter:description" content="为了丰富员工业余生活，增多交流机会，于是在公司搭建了论坛方便大家灌水，目前公司中企业级应用是基于JAVAEE的产品，论坛选用了比较受欢迎的Discuz 3.2, 为了避免二次登陆使用单点登陆解决，虽然查找了各种资料做集成，但是其中还是遇到了些问题，翻墙发现了：discuz-ucenter-api-for-java因为被墙，在国内无法访问code.google.com，已将测试代码做了部分调整上传至">
<meta name="twitter:image" content="http://static.nsoft.vip/16-9-18-7630535.jpg">
  <link rel="alternate" href="/atom.xml" title="疯狂的企鹅" type="application/atom+xml">
  <link rel="canonical" href="https://crazyrico.com/posts/2016/09/26/344d9fc6">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>JavaWeb整合Discuz实现单点登录 | 疯狂的企鹅</title>
  








  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">疯狂的企鹅</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">Crazy.Rico's Blog</p>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-links">
      
    

    <a href="/links/" rel="section"><i class="menu-item-icon fa fa-fw fa-chain"></i> <br>links</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>


    </div>
</nav>
</div>
    </header>

    

  <a href="https://github.com/crazyrico" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://crazyrico.com/posts/2016/09/26/344d9fc6.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Crazy Rico">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://static.nsoft.vip/penguin.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="疯狂的企鹅">
    </span>
      <header class="post-header">

        
          <h1 class="post-title" itemprop="name headline">JavaWeb整合Discuz实现单点登录

            
          </h1>
        

        <div class="post-meta">
		   
		  <!-- add by alex.yao 2019-10-17 begin -->
		   
		  <!-- add by alex.yao 2019-10-17 end -->
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2016-09-26 15:40:21" itemprop="dateCreated datePublished" datetime="2016-09-26T15:40:21+08:00">2016-09-26</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-10-16 16:06:47" itemprop="dateModified" datetime="2019-10-16T16:06:47+08:00">2019-10-16</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/其他/" itemprop="url" rel="index"><span itemprop="name">其他</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/其他/论坛/" itemprop="url" rel="index"><span itemprop="name">论坛</span></a></span>

                
                
              
            </span>
          

          
            <span class="post-meta-item" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>
            </span>
          
          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span>2.8k</span>
            </span>
          
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span>3 分钟</span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>为了丰富员工业余生活，增多交流机会，于是在公司搭建了论坛方便大家灌水，目前公司中企业级应用是基于JAVAEE的产品，论坛选用了比较受欢迎的Discuz 3.2, 为了避免二次登陆使用单点登陆解决，虽然查找了各种资料做集成，但是其中还是遇到了些问题，翻墙发现了：<br><a href="https://code.google.com/p/discuz-ucenter-api-for-java" target="_blank" rel="noopener">discuz-ucenter-api-for-java</a><br>因为被墙，在国内无法访问code.google.com，已将测试代码做了部分调整上传至GitHub:<br><a href="https://github.com/yaonew/discuz-ucenter_api_for_java" target="_blank" rel="noopener">https://github.com/yaonew/discuz-ucenter_api_for_java</a></p>
<h2 id="第一步配置config-properties"><a href="#第一步配置config-properties" class="headerlink" title="第一步配置config.properties"></a>第一步配置config.properties</h2><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">UC_API = http://你的discuz地址/uc_server  如http://localhost/bbs/uc_server</span><br><span class="line">UC_IP = 正常情况下留空即可</span><br><span class="line">UC_KEY = N3M117R45aWfqfe4xcu0OfTcAT3r4K6f2KRoUOFYT（与ucenter通信的密钥，这里自己设定，需与discuz ucenter 一致）</span><br><span class="line">UC_APPID = 2    //appID为UCenter中应用管理中的ID，见UCenter设置</span><br><span class="line">UC_CONNECT = 正常情况下留空即可</span><br></pre></td></tr></tbody></table></figure>

<h2 id="第二步-配置web-xml-添加如下"><a href="#第二步-配置web-xml-添加如下" class="headerlink" title="第二步 配置web.xml,添加如下"></a>第二步 配置web.xml,添加如下</h2><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&lt;servlet&gt;</span><br><span class="line">    &lt;servlet-name&gt;api&lt;/servlet-name&gt;</span><br><span class="line">    &lt;servlet-class&gt;com.fivestars.interfaces.bbs.api.UC&lt;/servlet-class&gt;</span><br><span class="line">    &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;</span><br><span class="line">&lt;/servlet&gt;</span><br><span class="line">&lt;servlet-mapping&gt;</span><br><span class="line">    &lt;servlet-name&gt;api&lt;/servlet-name&gt;</span><br><span class="line">    &lt;url-pattern&gt;/api/uc.php&lt;/url-pattern&gt;</span><br><span class="line">&lt;/servlet-mapping&gt;</span><br></pre></td></tr></tbody></table></figure>


<h2 id="第三步-配置ucenter"><a href="#第三步-配置ucenter" class="headerlink" title="第三步 配置ucenter"></a>第三步 配置ucenter</h2><p>管理员登陆UCenter : <a href="http://localhost/bbs/uc_server" target="_blank" rel="noopener">http://localhost/bbs/uc_server</a><br>应用管理-&gt; 添加应用, 这边添加的应用ID，通信秘钥与第一步的配置保持一致<br><img src="http://static.nsoft.vip/16-9-18-7630535.jpg" alt=""><br><img src="http://static.nsoft.vip/16-9-18-57860485.jpg" alt=""><br>配置完成，看到通信成功的信息，表示ucenter集成配置OK<br><img src="http://static.nsoft.vip/16-9-18-19780976.jpg" alt=""></p>
<h2 id="第四步-访问测试页"><a href="#第四步-访问测试页" class="headerlink" title="第四步 访问测试页"></a>第四步 访问测试页</h2><figure class="highlight jsp"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line">&lt;%<span class="meta">@page</span> <span class="keyword">import</span>=<span class="string">"java.util.LinkedList"</span>%&gt;</span><br><span class="line">&lt;%<span class="meta">@page</span> <span class="keyword">import</span>=<span class="string">"com.fivestars.interfaces.bbs.util.XMLHelper"</span>%&gt;</span><br><span class="line">&lt;%<span class="meta">@page</span> <span class="keyword">import</span>=<span class="string">"com.fivestars.interfaces.bbs.client.Client"</span>%&gt;</span><br><span class="line">&lt;%</span><br><span class="line">Client uc = <span class="keyword">new</span> Client();</span><br><span class="line"><span class="comment">//String result1 = uc.uc_user_register("test3", "test3", "test3@huaqi.info");</span></span><br><span class="line"><span class="comment">//out.println("xxx" + result1);</span></span><br><span class="line">String result = uc.uc_user_login(<span class="string">"test3"</span>, <span class="string">"test3"</span>);</span><br><span class="line"></span><br><span class="line">LinkedList&lt;String&gt; rs = XMLHelper.uc_unserialize(result);</span><br><span class="line"><span class="keyword">if</span>(rs.size()&gt;<span class="number">0</span>){</span><br><span class="line">    <span class="keyword">int</span> $uid = Integer.parseInt(rs.get(<span class="number">0</span>));</span><br><span class="line">    String $username = rs.get(<span class="number">1</span>);</span><br><span class="line">    String $password = rs.get(<span class="number">2</span>);</span><br><span class="line">    String $email = rs.get(<span class="number">3</span>);</span><br><span class="line">    <span class="keyword">if</span>($uid &gt; <span class="number">0</span>) {</span><br><span class="line">        response.addHeader(<span class="string">"P3P"</span>,<span class="string">" CP=\"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\""</span>);</span><br><span class="line"></span><br><span class="line">        out.println(<span class="string">"登录成功"</span>);</span><br><span class="line">        out.println($username);</span><br><span class="line">        out.println($password);</span><br><span class="line">        out.println($email);</span><br><span class="line"></span><br><span class="line">        String $ucsynlogin = uc.uc_user_synlogin($uid);</span><br><span class="line">        out.println(<span class="string">"登录成功"</span>+$ucsynlogin);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//本地登陆代码</span></span><br><span class="line">        <span class="comment">//TODO ... ....</span></span><br><span class="line">        Cookie auth = <span class="keyword">new</span> Cookie(<span class="string">"auth"</span>, uc.uc_authcode($password+<span class="string">"\t"</span>+$uid, <span class="string">"ENCODE"</span>));</span><br><span class="line">        auth.setMaxAge(<span class="number">31536000</span>);</span><br><span class="line">        <span class="comment">//auth.setDomain("localhost");</span></span><br><span class="line">        response.addCookie(auth);</span><br><span class="line"></span><br><span class="line">        Cookie user = <span class="keyword">new</span> Cookie(<span class="string">"uchome_loginuser"</span>, $username);</span><br><span class="line">        response.addCookie(user);</span><br><span class="line"></span><br><span class="line">    } <span class="keyword">else</span> <span class="keyword">if</span>($uid == -<span class="number">1</span>) {</span><br><span class="line">        out.println(<span class="string">"用户不存在,或者被删除"</span>);</span><br><span class="line">    } <span class="keyword">else</span> <span class="keyword">if</span>($uid == -<span class="number">2</span>) {</span><br><span class="line">        out.println(<span class="string">"密码错"</span>);</span><br><span class="line">    } <span class="keyword">else</span> {</span><br><span class="line">        out.println(<span class="string">"未定义"</span>);</span><br><span class="line">    }</span><br><span class="line">}<span class="keyword">else</span>{</span><br><span class="line">    out.println(<span class="string">"Login failed"</span>);</span><br><span class="line">    System.out.println(result);</span><br><span class="line">} </span><br><span class="line">%&gt;</span><br></pre></td></tr></tbody></table></figure>

<p>访问页面返回一段js：<br>登录成功<br>test3<br>test3<br><a href="mailto:test3@huaqi.info" target="_blank" rel="noopener">test3@huaqi.info</a><br>登录成功</p>
<figure class="highlight javascript"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;script type=<span class="string">"text/javascript"</span> src=<span class="string">"http://localhost/api/uc.php?time=1474188863&amp;amp;code=6dfdhvNXKRoUOFYTR3Jn3ORQ2LKDd6cI6X5p4RD3yxyh6gy3%2F%2FQAJ5u8URp7qR%2F%2F0jaIoha2g4MnGRtosanyDihDy%2BIyW0zNNAnjkGHoaC1uyga5U2py%2F6%2F4uolQKBJaVI%2FMsM%2BuFUlttWcSmS7mzQoN%2Be0tzvPFZg2Y"</span> reload=“<span class="number">1</span>”&lt;<span class="regexp">/script&gt;</span></span><br></pre></td></tr></tbody></table></figure>

<p>在浏览器中执行后访问 discus已保持登陆状态！</p>
<script>
        document.querySelectorAll('.github-emoji')
          .forEach(el => {
            if (!el.dataset.src) { return; }
            const img = document.createElement('img');
            img.style = 'display:none !important;';
            img.src = el.dataset.src;
            img.addEventListener('error', () => {
              img.remove();
              el.style.color = 'inherit';
              el.style.backgroundImage = 'none';
              el.style.background = 'none';
            });
            img.addEventListener('load', () => {
              img.remove();
            });
            document.body.appendChild(img);
          });
      </script>
    </div>

    
    
    
	
	<!-- add by alex.yao 2019-08-07 begin -->
	<div>
    
      <!-- add 2018-12-29 -->
<div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
    
    </div>
    <!-- add by alex.yao 2019-08-07 end -->
      <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center;">
  <img id="wechat_subscriber_qcode" src="http://static.nsoft.vip/qrcode_for_tec.jpg" alt="Crazy Rico wechat" style="width: 200px; max-width: 100%;">
  <div>欢迎您扫一扫上面的微信公众号，订阅我的博客！</div>
</div>

    
      <div>
        <div id="reward-container">
  <div></div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
        
      
      <div style="display: inline-block">
        <img src="http://static.nsoft.vip/weixin.png" alt="Crazy Rico 微信支付">
        <p>微信支付</p>
      </div>
        
      
      <div style="display: inline-block">
        <img src="http://static.nsoft.vip/alipay.jpg" alt="Crazy Rico 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

      </div>

    <footer class="post-footer">
          
        
        <div class="post-tags">
            <a href="/tags/java/" rel="tag"># java</a>
          
            <a href="/tags/web/" rel="tag"># web</a>
          
            <a href="/tags/discuz/" rel="tag"># discuz</a>
          
            <a href="/tags/php/" rel="tag"># php</a>
          
            <a href="/tags/单点登录/" rel="tag"># 单点登录</a>
          
        </div>
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
              <a href="/posts/2016/09/20/6778a1a4.html" rel="next" title="Hexo搭建GitHub个人博客系统">
                <i class="fa fa-chevron-left"></i> Hexo搭建GitHub个人博客系统
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
              <a href="/posts/2016/10/04/a10cb676.html" rel="prev" title="十一假期随笔">
                十一假期随笔 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
    </footer>
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    <div class="comments" id="gitalk-container"></div>
  


        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="http://static.nsoft.vip/penguin.png"
      alt="Crazy Rico">
  <p class="site-author-name" itemprop="name">Crazy Rico</p>
  <div class="site-description motion-element" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">33</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">39</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
  <div class="feed-link motion-element">
    <a href="/atom.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/crazyrico" title="GitHub &rarr; https://github.com/crazyrico" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://www.freecodecamp.cn/crazyrico" title="FCC &rarr; https://www.freecodecamp.cn/crazyrico" rel="noopener" target="_blank"><i class="fa fa-fw fa-globe"></i>FCC</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:crazyrico@qq.com" title="E-Mail &rarr; mailto:crazyrico@qq.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://s.imooc.com/ACFNlyI" title="慕课网 &rarr; https://s.imooc.com/ACFNlyI" rel="noopener" target="_blank"><i class="fa fa-fw fa-fire"></i>慕课网</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=gr9asv3c" title="阿里云 &rarr; https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=gr9asv3c" rel="noopener" target="_blank"><i class="fa fa-fw fa-cloud"></i>阿里云</a>
      </span>
    
  </div>



        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#第一步配置config-properties"><span class="nav-number">1.</span> <span class="nav-text">第一步配置config.properties</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二步-配置web-xml-添加如下"><span class="nav-number">2.</span> <span class="nav-text">第二步 配置web.xml,添加如下</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三步-配置ucenter"><span class="nav-number">3.</span> <span class="nav-text">第三步 配置ucenter</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第四步-访问测试页"><span class="nav-number">4.</span> <span class="nav-text">第四步 访问测试页</span></a></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">  <a href="http://www.beian.miit.gov.cn" rel="noopener" target="_blank">苏ICP备17004952号 </a>&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Crazy Rico</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">90k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">1:22</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.3.0</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item-icon">
      <i class="fa fa-user"></i>
    </span>
    <span class="site-uv" title="总访客量">
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  
    <span class="post-meta-divider">|</span>
  
    <span class="post-meta-item-icon">
      <i class="fa fa-eye"></i>
    </span>
    <span class="site-pv" title="总访问量">
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>


  <!--
  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=true&web_id=true"></script>
  </div>
  -->
  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1278118065'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s9.cnzz.com/z_stat.php%3Fid%3D1278118065%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));</script>






        
      </div>
    </footer>
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/affix.js?v=7.3.0"></script>
  <script src="/js/schemes/pisces.js?v=7.3.0"></script>



<script src="/js/next-boot.js?v=7.3.0"></script>






  















  <script src="/js/local-search.js?v=7.3.0"></script>













<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', function() {
    var gitalk = new Gitalk({
      clientID: '9255016b522a1b91949f',
      clientSecret: 'a0344ceccbd072ddf864ace66c89f73e53bfb671',
      repo: 'CrazyRico.github.io',
      owner: 'CrazyRico',
      admin: ['CrazyRico'],
      id: '516a35d265e49707e113184afbcbb8c8',
        language: window.navigator.language || window.navigator.userLanguage,
      
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>




  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', function() {
    var gitalk = new Gitalk({
      clientID: '9255016b522a1b91949f',
      clientSecret: 'a0344ceccbd072ddf864ace66c89f73e53bfb671',
      repo: 'CrazyRico.github.io',
      owner: 'CrazyRico',
      admin: ['CrazyRico'],
      id: '202cf610ee9b9446542c91b5d43378c6',
        language: window.navigator.language || window.navigator.userLanguage,
      
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>

</body>
</html>
